package com.xbongbong.paas.pojo.dto;

import com.xbongbong.paas.domain.entity.ext.PaasAttachmentEntityExt;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
@ToString
public class CommentEditDTO extends BaseDTO {
    private static final long serialVersionUID = 773189043448180730L;

    @NotNull(message = "dto.msg.commentDetail.dataId.NotNull")
    private Long commentId;

    @NotNull(message = "{dto.msg.commentAdd.appId.NotNull}")
    private Long appId;
    /**
     * 引用id
     */
    @NotNull(message = "{dto.msg.commentAdd.refId.NotNull}")
    private Long refId;

    /**
     * 评论内容
     */
    @NotBlank(message = "{dto.msg.commentAdd.content.NotBlank}")
    @Size(max = 2000,message = "{dto.msg.commentAdd.content.Size}")
    private String content;

    private Long dataId;

    /**
     * 被回复人user_id
     */
    private String refUserId;

    /**
     * 艾特的用户id
     */
    private List<String> atUserIds;

    /**
     * 图片列表
     */
    private List<String> images;

    /**
     * 文件列表
     */
    @Valid
    private List<PaasAttachmentEntityExt> attachmentList;

    /**
     * 业务类型
     */
    @NotNull(message = "{dto.msg.commentAdd.businessType.NotNull}")
    private Integer businessType;

    /**
     * 本表单的saasMark
     * @see com.xbongbong.pro.enums.SaasMarkEnum
     */
    private Integer saasMark;

    /**
     * 是否是回复类型的评论
     */
    private Boolean isReply;

    public Boolean isReply() {
        if (this.isReply == null){
            return false;
        }
        return this.isReply;
    }

    public CommentEditDTO(){
        content = "";
        refUserId = "";
        images = new ArrayList<>();
        attachmentList = new ArrayList<>();
    }

    public void setAtUserIds(List<String> atUserIds) {
        this.atUserIds = atUserIds == null ? new ArrayList<>() : atUserIds;
    }
}
